<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>详情</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no,email=no,address=no"/>
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <link rel="stylesheet" href="../css/common.css"/>
    <link rel="stylesheet" href="../css/main.css"/>
</head>
<body>
    <article class="bigBox" id="details">
        <!--<section class="container">-->
            <!--<div class="lh70 plr24 bw mb20">订单状态：<span class="color2">待发货</span></div>-->
            <!--<div class="plr24 bw">-->
                <!--<div class="flex_sb bdb ptb24">-->
                    <!--<div class="flex1 flex_a">-->
                        <!--<img src="../img/ico32.png" style="width: .4rem;">-->
                        <!--<div class="ml20">-->
                            <!--<p>快件离开北京,正发往东莞</p>-->
                            <!--<p class="mt10">2017-05-17 12:05:15</p>-->
                        <!--</div>-->
                    <!--</div>-->
                    <!--<div class="arrow_right flex_a ml20">-->
                        <!--<img src="../img/arrow_right.png"/>-->
                    <!--</div>-->
                <!--</div>-->
            <!--</div>-->
            <!--<div class="flex_a p24 bw">-->
                <!--<div class="flex_aj"><img src="../img/ico17.png" style="width: .3rem;"></div>-->
                <!--<div class="flex1 ml24">-->
                    <!--<p class="flex_sb">-->
                        <!--<span>收货人: 陈先生</span>-->
                        <!--<cite>13632347040</cite>-->
                    <!--</p>-->
                    <!--<p class="col9 mt10">广东省东莞市dddd</p>-->
                <!--</div>-->
            <!--</div>-->
            <!--<div class="bw plr24 mt10">-->
                <!--<div class="ptb30 flex_a bdb">-->
                    <!--<div><img src="../img/test.png" class="goods_pic"></div>-->
                    <!--<div class="flex1 ml20">-->
                        <!--<p>清风纸巾</p>-->
                        <!--<p class="font12 col9">分类：日用品</p>-->
                        <!--<p class="flex_sb">-->
                            <!--<span class="color2">￥2.00</span>-->
                            <!--<cite class="col9">x1</cite>-->
                        <!--</p>-->
                    <!--</div>-->
                <!--</div>-->
                <!--<p class="flex_sb lh90 bdb">-->
                    <!--<span>商品总价</span>-->
                    <!--<cite class="col9">￥2.00</cite>-->
                <!--</p>-->
                <!--<p class="flex_sb lh90">-->
                    <!--<span>实付款</span>-->
                    <!--<cite class="color2">￥2.00</cite>-->
                <!--</p>-->
            <!--</div>-->
            <!--<div class="ptb20 bw plr24 mt10">-->
                <!--<p>订单编号: <span class="col9">16463463463</span></p>-->
                <!--<p class="mt10">交易号: <span class="col9">16463463463</span></p>-->
                <!--<p class="mt10">创建时间: <span class="col9">2017-06-06 12:26:12</span></p>-->
                <!--<p class="mt10">付款时间: <span class="col9">2017-06-06 12:26:12</span></p>-->
                <!--<p class="mt10">发货时间: <span class="col9">2017-06-06 12:26:12</span></p>-->
                <!--<p class="mt10">收货时间: <span class="col9">2017-06-06 12:26:12</span></p>-->
            <!--</div>-->
            <!--<div class="mt10 plr24 bw">-->
                <!--<p class="lh90 bdb">物流信息</p>-->
                <!--<div class="ptb20">-->
                    <!--<p>物流公司：<span class="col9">德邦物流</span></p>-->
                    <!--<p class="mt10">物流单号：<span class="col9">243434343413</span></p>-->
                <!--</div>-->
            <!--</div>-->
        <!--</section>-->
        <!--<footer class="ptb20 pw100 bgf5">-->
            <!--<div class="plr30">-->
                <!--<button class="border-r6 bgc1 colw tac lh90 pw100 btn_tap">发货</button>-->
            <!--</div>-->
        <!--</footer>-->
    </article>
    <article class="model_pane dpn">
        <section class="plr100 pt200">
            <div class="bw border-r1">
                <p class="font17 ptb30 tac fw">发货</p>
                <div class="plr50">
                    <div class="border1 flex_sb h60" onclick="$('.logistics').show();">
                        <input type="text" placeholder="选择物流公司" class="pl20 flex1" readonly id="logistics_name">
                        <img src="../img/ico18.png" style="width: .1rem;" class="mlr20">
                    </div>
                    <div class="border1 flex_sb h60 mt20">
                        <input type="text" placeholder="请输入物流单号" class="pl20 flex1" id="logisticsNo">
                    </div>
                </div>
                <div class="flex lh90 mt60 bdt tac">
                    <div class="flex1 col9" onclick="$('.model_pane').hide();">取消</div>
                    <div class="flex1 color1 bdl" id="addLogistics">确定</div>
                </div>
            </div>
        </section>
    </article>
    <article class="bgf5 logistics dpn">
        <ul class="plr24 bw" id="logistics_list">
            <!--<li class="lh90 bdb">德邦物流</li>-->
            <!--<li class="lh90 bdb">百世汇通</li>-->
            <!--<li class="lh90 bdb">申通快递</li>-->
            <!--<li class="lh90 bdb">圆通快递</li>-->
            <!--<li class="lh90 bdb">全峰快递</li>-->
            <!--<li class="lh90 bdb">EMS小包</li>-->
            <!--<li class="lh90 bdb">邮政快递</li>-->
        </ul>
    </article>
</body>
</html>
<script src="../js/jquery-1.8.3.min.js"></script>
<script src="../js/dlc.js"></script>
<script src="../js/courier.js"></script>
<script>
    var producer = '',orderNo='',company_no='';
    dlc_request('/api/myOrder/OrderDetailList',{'orderNo':getUrlParam('orderNo')}, function(res){
        console.log(res);
        if(res.code == 1){
            var str = '';
            var res = res.data[0];
            producer = res.producer;
            orderNo = res.orderNo;
            str+='<section class="container">'+
                    '<div class="lh70 plr24 bw mb20">订单状态：<span class="'+(res.status==0?'color2':res.status==1?'color3':res.status==2?'color4':res.status==3?'col9':'')+'">'+(res.status==0?"待付款":res.status==1?"待发货":res.status==2?"待收货":res.status==3?"已完成":"未知状态")+'</span></div>';
            if(res.status == 2 || res.status == 3){
                str+='<div class="plr24 bw" id="logistics">'+
                        '<div class="flex_sb bdb ptb24">'+
                        '<div class="flex1 flex_a">'+
                        '<img src="../img/ico32.png" style="width: .4rem;">'+
                        '<div class="ml20">'+
                        '<p id="endText"></p>'+
                '<p class="mt10" id="endTime"></p>'+
                '</div>'+
                '</div>'+
                '<div class="arrow_right flex_a ml20">'+
                        '<img src="../img/arrow_right.png"/>'+
                        '</div>'+
                        '</div>'+
                        '</div>';
            }
            str+='<div class="flex_a p24 bw">'+
                    '<div class="flex_aj"><img src="../img/ico17.png" style="width: .3rem;"></div>'+
                    '<div class="flex1 ml24">'+
                    '<p class="flex_sb">'+
                    '<span>收货人: '+res.name+'</span>'+
            '<cite>'+res.phone+'</cite>'+
            '</p>'+
            '<p class="col9 mt10">'+res.addr+'</p>'+
                    '</div>'+
                    '</div>'+
                    '<div class="bw plr24 mt10">';
            for(var i in res.goodsInfo){
                str+='<div class="ptb30 flex_a bdb">'+
                        '<div><img src="'+res.goodsInfo[i].imgUrl+'" class="goods_pic"></div>'+
                        '<div class="flex1 ml20">'+
                        '<p>'+res.goodsInfo[i].goodsName+'</p>'+
                        '<p class="font12 col9">分类：'+res.goodsInfo[i].categoryName+'</p>'+
                '<p class="flex_sb">'+
                        '<span class="color2">￥'+res.goodsInfo[i].price+'</span>'+
                '<cite class="col9">x'+(res.goodsInfo[i].orderNum?res.goodsInfo[i].orderNum:0)+'</cite>'+
                        '</p>'+
                        '</div>'+
                        '</div>';
            }
            str+='<p class="flex_sb lh90 bdb">'+
                    '<span>商品总价</span>'+
                    '<cite class="col9">￥'+res.goodsSum+'</cite>'+
            '</p>'+
            '<p class="flex_sb lh90">'+
                    '<span>实付款</span>'+
                    '<cite class="color2">￥'+res.realPayment+'</cite>'+
            '</p>'+
            '</div>'+
            '<div class="ptb20 bw plr24 mt10">'+
                    '<p>订单编号: <span class="col9">'+res.orderNo+'</span></p>'+
            '<p class="mt10">交易号: <span class="col9">'+res.transactionNo+'</span></p>'+
            '<p class="mt10">创建时间: <span class="col9">'+format(res.createTime,'Y-m-d H:i:s')+'</span></p>';
            if(res.status>0){
                str+='<p class="mt10">付款时间: <span class="col9">'+format(res.payTime,'Y-m-d H:i:s')+'</span></p>';
            }
            if(res.status == 2 || res.status == 3){
                str+='<p class="mt10">发货时间: <span class="col9">'+(res.deliveryTime?format(res.deliveryTime,'Y-m-d H:i:s'):res.deliveryTime)+'</span></p>';
            }
            if(res.status == 3){
                str+='<p class="mt10">收货时间: <span class="col9">'+(res.tradeTime?format(res.tradeTime,'Y-m-d H:i:s'):res.tradeTime)+'</span></p>';
            }
            str+='</div>';
            if(res.status>1){
                str+='<div class="mt10 plr24 bw">'+
                        '<p class="lh90 bdb">物流信息</p>'+
                        '<div class="ptb20">'+
                        '<p>物流公司：<span class="col9">'+res.logisticsName+'</span></p>'+
                '<p class="mt10">物流单号：<span class="col9">'+res.logisticsNo+'</span></p>'+
                '</div>'+
                '</div>';
            }
            str+='</section>';
            if(res.status == 1){
                str+='<footer class="ptb20 pw100 bgf5">'+
                        '<div class="plr30">'+
                        '<button class="border-r6 bgc1 colw tac lh90 pw100 btn_tap" id="delivery">发货</button>'+
                        '</div>'+
                        '</footer>';
            }
            $('#details').html(str);
            if(res.status>1){
                dlc_request('/api/express/queryExpressLastMsg',{'nu':res.logisticsNo}, function(res){
                    console.log(res);
                    if(res.code == 1){
                        if(res.resultItemList.length>0){
                            $('#endText').text(res.resultItemList[0].context);
                            $('#endTime').text(res.resultItemList[0].time);
                            $('#details').on('click','#logistics',function(){
                                location.href = './supply_logistics.html?orderNo='+getUrlParam('orderNo');
                            });
                        }else{
                            $('#endText').text('物流更新中，请耐心等待！');
                            $('#endTime').text(format(new Date().getTime(),'Y-m-d H:i:s'));
                            $('#details').on('click','#logistics',function(){
                               dlctipbox.show('物流信息更新中，请耐心等候！');
                            });
                        }
                    }else{
                        dlctipbox.show(res.msg);
                    }
                });
            }
        }else{
            dlctipbox.show(res.msg);
        }
    });
    $('#details').on('click','#delivery',function(){
        $('.model_pane').show();
    });
    var str = '';
    for(var i in courier){
        str+='<li class="lh90 bdb courier tap" data-no="'+courier[i].no+'">'+courier[i].name+'</li>';
    }
    $('#logistics_list').html(str);
    $('#logistics_list').on('click','.courier',function(){
        console.log($(this).text());
        console.log($(this).data('no'));
        company_no = $(this).data('no');
        $('#logistics_name').val($(this).text());
        $('#logistics_name').attr('data-no',$(this).data('no'));
        $('.logistics').hide();
    });
    $('#addLogistics').click(function(){
        if(producer){
            if(isNull($('#logistics_name').val()) || company_no == ''){
                dlctipbox.show('请选择物流公司');
            }else if(isNull($('#logisticsNo').val())){
                dlctipbox.show('请输入物流单号');
            }else{
                let param = {
                    company:company_no,
                    number:$('#logisticsNo').val()
                };
                dlc_request('/api/express/queryExpress',{param:JSON.stringify(param)}, function(res){
                    console.log(res);
                    if(res.code == 1){
                        var data = {
                            'logisticsNo':$('#logisticsNo').val(),
                            'logisticsName':$('#logistics_name').val(),
                            'producer':producer,
                            'orderNo':orderNo,
                            'company':company_no
                        };
                        console.log(data);
                        dlc_request('/api/myOrder/AddLogistics',data, function(res){
                            if(res.code == 1){
                                dlc_request('/api/myOrder/ChangeOrderStatus',{'orderNo':orderNo,'status':2}, function(res){
                                    if(res.code == 1){
                                        setTimeout(function(){
                                            history.go(-1);
                                        },1500);
                                    }
                                    dlctipbox.show(res.msg);
                                });
                            }else{
                                dlctipbox.show(res.msg);
                            }
                        });
                    }else{
                        dlctipbox.show(res.msg);
                    }
                });
            }
        }
    });
</script>






















